<?php

namespace App\Model\Logistics;

use Illuminate\Database\Eloquent\Model;

class Plan extends Model
{
    protected $table = 'v_logistics_plan';

    protected $primaryKey = [
        'id', 'order_id'
    ];

    public $incrementing = false;
    public $timestamps = false;

    protected $fillable = [
        'id' => 'id',
        'type' => 'type',
        'product_id' => 'product_id', // 产品ID
        // 总计
	    'qty' => 'qty', // 总数量
	    'qty_ctn' => 'qty_ctn', // 装箱率
        // 中间的不确定的情形
        'shipable_qty' => 'shipable_qty', // 可发数量
        'expected_qty' => 'expected_qty', // 预计可发数量
        'expected_date' => 'expected_date', // 预计到货日期
        // 执行的情况
        'planned_qty' => 'planned_qty', // 计划数量
        'shipped_qty' => 'shipped_qty', // 已发数量

        'purchase_id' => 'purchase_id',  // 采购明细ID

        'label' => 'label', // 外箱标签规格
        'order_id' => 'order_id', // 货代物流单号
        'warehouse_id' => 'warehouse_id', // 仓库ID
        'transport_type' => 'transport_type', // 物流方式
        'customs_type' => 'customs_type', // 报关类型

        'ctn_weight' => 'ctn_weight',
        'ctn_g_weight' => 'ctn_g_weight',
        'ctn_length' => 'ctn_length',
        'ctn_width' => 'ctn_width',
        'ctn_height' => 'ctn_height',
        'remark' => 'remark',
        'sku' => 'sku',
    ];


    protected $attributes = [
		'order_id' => 3,
    ];
    


    protected $casts = [
	    'ctn' => 'int',
	    'qty' => 'int',
	    'qty_ctn' => 'int',
	    'planned_ctn_of_all' => 'int',
	    'expected_ctn' => 'int',
	    'shipable_ctn' => 'int',
	    'unplanned_ctn' => 'int',
	    'planned_ctn' => 'int',
        'ctn_weight' => 'float',
        'ctn_g_weight' => 'float',
        'ctn_length' => 'float',
        'ctn_width' => 'float',
        'ctn_height' => 'float',
        'ctn_volume_m' => 'float',
    ];


    protected static $translation = [
        'type' => [
            1 => '采购直发', // 采购单撤销时 可删除
            2 => '跨境调拨', // 调拨单修改时候 可删除
        ],
    ];

}
